<html>
<head>
<link rel="stylesheet" href="../../../js/sh/SyntaxHighlighter.css" type="text/css" />
<script src="../../../js/sh/shCore.js"></script>
<script src="../../../js/sh/shBrushJava.js"></script>
<style>

* {
font-family:Courier New,monospace;
  padding: 0;
  margin: 0;
  white-space: nowrap;
  font-size: 11px;
}

.dp-highlighter {
  white-space: nowrap;
  overflow: visible;
  width: 600px;
  font-size: 11px;
  font-family:Courier New,monospace;
}
</style>

</head>
<body>
<textarea name="code" class="java:nogutter" rows="15" cols="120">
/*
 * SmartGWT (GWT for SmartClient)
 * Copyright 2008 and beyond, Isomorphic Software, Inc.
 *
 * SmartGWT is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation.  SmartGWT is also
 * available under typical commercial license terms - see
 * http://smartclient.com/license
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 */

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;

import java.util.Date;

public class MultilineSample implements EntryPoint {

    public void onModuleLoad() {
        ListGrid countryGrid = new ListGrid();
        countryGrid.setWidth("100%");
        countryGrid.setHeight("100%");
        countryGrid.setAlternateRecordStyles(true);
        countryGrid.setShowAllRecords(true);
        countryGrid.setWrapCells(true);
        countryGrid.setCellHeight(56);

        ListGridField nameField = new ListGridField("countryName", "Country", 120);
        ListGridField backgroundField = new ListGridField("background", "Background");
        ListGridField countryCodeField = new ListGridField("countryCode", "Flag", 50);
        countryCodeField.setAlign(Alignment.CENTER);
        countryCodeField.setType(ListGridFieldType.IMAGE);
        countryCodeField.setImageSize(24);
        countryCodeField.setImageURLPrefix("flags/24/");
        countryCodeField.setImageURLSuffix(".png");

        countryGrid.setFields(new ListGridField[]{nameField, backgroundField, countryCodeField});

        countryGrid.setData(getRecords());

        countryGrid.setMargin(10);
        countryGrid.draw();
    }

    private ListGridRecord[] getRecords() {
        return new CountryRecord[]{
                new CountryRecord("North America", "United States", "US", 9631420, 298444215, 12360000,
                        new Date(1776, 6, 4), "federal republic", 2, "Washington, DC", true,
                        "http://en.wikipedia.org/wiki/United_states", "Britain's American colonies broke with " +
                                "the mother country in 1776 and were recognized as the new nation of the United States " +
                                "of America following the Treaty of Paris in 1783. During the 19th and 20th centuries..."),

                new CountryRecord("Asia", "China", "CH", 9596960, 1313973713, 8859000, null, "Communist state", 0,
                        "Beijing", false, "http://en.wikipedia.org/wiki/China", "For centuries China stood as a " +
                                "leading civilization, outpacing the rest of the world in the arts and sciences, but in the " +
                                "19th and early 20th centuries, the country was beset by civil unrest, major famines, ..."),

                new CountryRecord("Asia", "Japan", "JA", 377835, 127463611, 4018000, null,
                        "constitutional monarchy with parliamentary government", 1, "Tokyo", true,
                        "http://en.wikipedia.org/wiki/Japan", "In 1603, a Tokugawa shogunate (military dictatorship) " +
                                "ushered in a long period of isolation from foreign influence in order to secure its power. " +
                                "For 250 years this policy enabled Japan to enjoy stability and a flowering of its indigenous ..."),

                new CountryRecord("Asia", "India", "IN", 3287590, 1095351995, 3611000, new Date(1947, 7, 15), "federal republic", 2,
                        "New Delhi", false, "http://en.wikipedia.org/wiki/India", "The Indus Valley civilization, one of " +
                                "the oldest in the world, dates back at least 5,000 years. Aryan tribes from the northwest infiltrated " +
                                "onto Indian lands about 1500 B.C.; their merger with the earlier Dravidian inhabitants created ..."),

                new CountryRecord("Europe", "Germany", "GM", 357021, 82422299, 2504000, new Date(1871, 0, 18), "federal republic", 2,
                        "Berlin", true, "http://en.wikipedia.org/wiki/Germany", "As Europe's largest economy and second " +
                                "most populous nation, Germany remains a key member of the continent's economic, political, and defense " +
                                "organizations. European power struggles immersed Germany in two devastating World Wars in the first half " +
                                "of the 20th century and left the country occupied by the victorious Allied powers of the US, UK, ..."),

                new CountryRecord("Europe", "United Kingdom", "UK", 244820, 60609153, 1830000, new Date(1801, 0, 1), "constitutional monarchy", 1,
                        "London", true, "http://en.wikipedia.org/wiki/United_kingdom", "Great Britain, the dominant industrial " +
                                "and maritime power of the 19th century, played a leading role in developing parliamentary democracy and " +
                                "in advancing literature and science. At its zenith, the British Empire stretched over one-fourth of the ..."),


                new CountryRecord("Europe", "France", "FR", 547030, 60876136, 1816000, null, "republic", 5, "Paris", true,
                        "http://en.wikipedia.org/wiki/France", "Although ultimately a victor in World Wars I and II, " +
                                "France suffered extensive losses in its empire, wealth, manpower, and rank as a dominant nation-state. " +
                                "Nevertheless, France today is one of the most modern countries in the world and is a leader among European " +
                                "nations. Since 1958, it has constructed a presidential democracy resistant to the instabilities ..."),

                new CountryRecord("Europe", "Italy", "IT", 301230, 58133509, 1698000, new Date(1861, 2, 17), "republic", 5,
                        "Rome", true, "http://en.wikipedia.org/wiki/Italy", "Italy became a nation-state in 1861 " +
                                "when the regional states of the peninsula, along with Sardinia and Sicily, were united " +
                                "under King Victor EMMANUEL II. An era of parliamentary government came to a close in the " +
                                "early 1920s when Benito MUSSOLINI established a Fascist dictatorship. His disastrous ..."),

                new CountryRecord("Europe", "Russia", "RS", 17075200, 142893540, 1589000, new Date(1991, 7, 24), "federation", 3,
                        "Moscow", true, "http://en.wikipedia.org/wiki/Russia", "Founded in the 12th century, the" +
                                " Principality of Muscovy, was able to emerge from over 200 years of Mongol domination " +
                                "(13th-15th centuries) and to gradually conquer and absorb surrounding principalities..."),

                new CountryRecord("South America", "Brazil", "BR", 8511965, 188078227, 1556000, new Date(1822, 8, 7),
                        "federative republic", 3, "Brasilia", false, "http://en.wikipedia.org/wiki/Brazil",
                        "Following three centuries under the rule of Portugal, Brazil became an independent " +
                                "nation in 1822 and a republic in 1889. By far the largest and most populous country " +
                                "in South America, Brazil overcame more than half a century of military intervention ...")
        };
    }

}

class CountryRecord extends ListGridRecord {

    public CountryRecord() {
    }

    public CountryRecord(String continent, String countryName, String countryCode, int area, int population, double gdp,
                         Date independence, String government, int governmentDesc, String capital, boolean memberG8, String article,
                         String background) {

        setContinent(continent);
        setCountryName(countryName);
        setCountryCode(countryCode);
        setArea(area);
        setPopulation(population);
        setGdp(gdp);
        setIndependence(independence);
        setGovernment(government);
        setGovernmentDesc(governmentDesc);
        setCapital(capital);
        setMemberG8(memberG8);
        setArticle(article);
        setBackground(background);
    }

    public void setContinent(String continent) {
        setAttribute("continent", continent);
    }

    public String getContinent() {
        return getAttributeAsString("continent");
    }

    public void setCountryName(String countryName) {
        setAttribute("countryName", countryName);
    }

    public String getCountryName() {
        return getAttributeAsString("countryName");
    }

    public void setCountryCode(String countryCode) {
        setAttribute("countryCode", countryCode);
    }

    public String getCountryCode() {
        return getAttributeAsString("countryCode");
    }

    public void setArea(int area) {
        setAttribute("area", area);
    }

    public int getArea() {
        return getAttributeAsInt("area");
    }

    public void setPopulation(int population) {
        setAttribute("population", population);
    }

    public int getPopulation() {
        return getAttributeAsInt("population");
    }

    public void setGdp(double gdp) {
        setAttribute("gdp", gdp);
    }

    public double getGdp() {
        return getAttributeAsDouble("gdp");
    }

    public void setIndependence(Date independence) {
        setAttribute("independence", independence);
    }

    public Date getIndependence() {
        return getAttributeAsDate("independence");
    }

    public void setGovernment(String government) {
        setAttribute("government", government);
    }

    public String getGovernment() {
        return getAttributeAsString("government");
    }

    public void setGovernmentDesc(int governmentDesc) {
        setAttribute("government_desc", governmentDesc);
    }

    public int getGovernmentDesc() {
        return getAttributeAsInt("government_desc");
    }

    public void setCapital(String capital) {
        setAttribute("capital", capital);
    }

    public String getCapital() {
        return getAttributeAsString("capital");
    }

    public void setMemberG8(boolean memberG8) {
        setAttribute("member_g8", memberG8);
    }

    public boolean getMemberG8() {
        return getAttributeAsBoolean("member_g8");
    }


    public void setArticle(String article) {
        setAttribute("article", article);
    }

    public String getArticle() {
        return getAttributeAsString("article");
    }

    public void setBackground(String background) {
        setAttribute("background", background);
    }

    public String getBackground() {
        return getAttributeAsString("background");
    }
}
</textarea>
<script class="javascript">
dp.SyntaxHighlighter.HighlightAll('code');
</script>
</body>
</html>
